﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Xajhzwb.Components.Util;

namespace Xajhzwb.Components.Data
{
    public class DataHelper
    {
        public static string sql = "";
        public static QueryParameterCollection collection = null;

        #region DatabaseProperty
        private static DatabaseProperty accessProperty
        {
            get
            {
                DatabaseProperty defaultProperty = new DatabaseProperty();
                defaultProperty.ConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}\\Database\\ET.mdb;",
                                                                 @"E:\QidorSpider\TestABC\\");
                defaultProperty.DatabaseType = DatabaseType.OleDBSupported;
                return defaultProperty;
            }
        }

        private static DatabaseProperty mssqlProperty
        {
            get
            {
                DatabaseProperty defaultProperty = new DatabaseProperty();
                defaultProperty.ConnectionString = string.Format("server=foolnet-3fa9be8;database=WebsharpTest;uid=sa;pwd=",
                                                                 Utils.StartupPath);
                defaultProperty.DatabaseType = DatabaseType.OleDBSupported;
                return defaultProperty;
            }
        }

        private static DatabaseProperty oracleProperty
        {
            get
            {
                DatabaseProperty defaultProperty = new DatabaseProperty();
                defaultProperty.ConnectionString = string.Format("Data Source=websharp;user id=foolnet;pwd=foolnet",
                                                                 Utils.StartupPath);
                defaultProperty.DatabaseType = DatabaseType.OleDBSupported;
                return defaultProperty;
            }
        }
        #endregion

        public static DataAccess dataAccess = DataAccessFactory.CreateDataAccess(accessProperty);

        #region Rule_Publish ok
        public static List<PublishData> GetPublishNameList(int classID)
        {
            List<PublishData> publishDataList = new List<PublishData>();

            sql = "select ID,Name from Rule_Publish where ClassID = @ClassID";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@ClassID", classID, DbType.Int32);

            DataTable resultTable = dataAccess.ExecuteDataset(sql, collection).Tables[0];
            if (resultTable != null && resultTable.Rows.Count > 0)
            {
                foreach (DataRow row in resultTable.Rows)
                {
                    PublishData publishData = new PublishData();
                    publishData.ID = TypeConverter.ObjectToInt(row["ID"]);
                    publishData.Name = row["Name"].ToString();

                    publishDataList.Add(publishData);
                }
            }

            return publishDataList;
        }

        public static PublishData GePublishData(int ID)
        {
            PublishData publishData = new PublishData();

            try
            {
                sql = "select * from Rule_Publish where ID=@ID";

                QueryParameterCollection collection = new QueryParameterCollection();
                collection.Add("@ID", ID, DbType.Int32);

                dataAccess.Open();

                IDataReader reader = dataAccess.ExecuteReader(sql, collection);
                while (reader.Read())
                {
                    publishData.ID = TypeConverter.StrToInt(reader["ID"].ToString());
                    publishData.Name = reader["name"].ToString();
                    publishData.UrlChk = reader["UrlChk"].ToString();
                    publishData.UrlPost = reader["UrlPost"].ToString();
                    publishData.UrlReply = reader["UrlReply"].ToString();
                    publishData.IsReply = TypeConverter.StrToBool(reader["IsReply"].ToString(), false);
                    publishData.TitleMin = TypeConverter.StrToInt(reader["TitleMin"].ToString());
                    publishData.TitleMax = TypeConverter.StrToInt(reader["TitleMax"].ToString());
                    publishData.ContentMin = TypeConverter.StrToInt(reader["ContentMin"].ToString());
                    publishData.ContentMax = TypeConverter.StrToInt(reader["ContentMax"].ToString());
                    publishData.IsUbb = TypeConverter.StrToBool(reader["IsUbb"].ToString(), false);
                    publishData.IsCrlf = TypeConverter.StrToBool(reader["IsCrlf"].ToString(), false);
                    publishData.CodePage = reader["CodePage"].ToString();
                    publishData.IsForcePost = TypeConverter.StrToBool(reader["IsForcePost"].ToString(), false);
                    publishData.PostSort = TypeConverter.StrToInt(reader["PostSort"].ToString());
                    publishData.IsSelfChk = TypeConverter.StrToBool(reader["IsSelfChk"].ToString(), false);
                    publishData.ChkMode = TypeConverter.StrToInt(reader["ChkMode"].ToString());
                    publishData.PostTitle = reader["PostTitle"].ToString();
                    publishData.PostContent = reader["PostContent"].ToString();
                    publishData.PostParas = reader["PostParas"].ToString();
                    publishData.PostOtherParas = reader["PostOtherParas"].ToString();
                    publishData.PostUsers = reader["PostUsers"].ToString();
                    publishData.IsFtp = TypeConverter.StrToBool(reader["IsFtp"].ToString(), false);
                    publishData.IsFtpPasv = TypeConverter.StrToBool(reader["IsFtpPasv"].ToString(), false);
                    publishData.FtpServer = reader["FtpServer"].ToString();
                    publishData.FtpPort = TypeConverter.StrToInt(reader["FtpPort"].ToString());
                    publishData.FtpUser = reader["FtpUser"].ToString();
                    publishData.FtpPass = reader["FtpPass"].ToString();
                    publishData.FtpDir = reader["FtpDir"].ToString();
                    publishData.IsDelDownFile = TypeConverter.StrToBool(reader["IsDelDownFile"].ToString(), true);
                    publishData.TransLang = TypeConverter.StrToInt(reader["TransLang"].ToString());
                    publishData.TransParas = reader["TransParas"].ToString();
                    publishData.IsLogin = TypeConverter.StrToBool(reader["IsLogin"].ToString(), false);
                    publishData.LoginUrl = reader["LoginUrl"].ToString();
                    publishData.PostCookies = reader["PostCookies"].ToString();
                    publishData.PostOkCode = reader["PostOkCode"].ToString();
                    publishData.Sort = TypeConverter.StrToInt(reader["Sort"].ToString());
                    publishData.ClassID = TypeConverter.StrToInt(reader["ClassID"].ToString());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dataAccess.Close();
            }

            return publishData;
        }

        public static int InsPublishData(PublishData publishData)
        {
            sql = "insert into Rule_Publish(Name,UrlChk,UrlPost,UrlReply,IsReply,TitleMin,TitleMax,ContentMin,ContentMax,IsUbb,IsCrlf,CodePage,IsForcePost,PostSort,IsSelfChk,ChkMode,PostTitle,PostContent,PostParas,PostOtherParas,PostUsers,IsFtp,IsFtpPasv,FtpServer,FtpPort,FtpUser,FtpPass,FtpDir,IsDelDownFile,TransLang,TransParas,IsLogin,LoginUrl,PostCookies,PostOkCode,Sort,ClassID) values(@Name,@UrlChk,@UrlPost,@UrlReply,@IsReply,@TitleMin,@TitleMax,@ContentMin,@ContentMax,@IsUbb,@IsCrlf,@CodePage,@IsForcePost,@PostSort,@IsSelfChk,@ChkMode,@PostTitle,@PostContent,@PostParas,@PostOtherParas,@PostUsers,@IsFtp,@IsFtpPasv,@FtpServer,@FtpPort,@FtpUser,@FtpPass,@FtpDir,@IsDelDownFile,@TransLang,@TransParas,@IsLogin,@LoginUrl,@PostCookies,@PostOkCode,@Sort,@ClassID)";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@Name", publishData.Name, DbType.String);
            collection.Add("@UrlChk", publishData.UrlChk, DbType.String);
            collection.Add("@UrlPost", publishData.UrlPost, DbType.String);
            collection.Add("@UrlReply", publishData.UrlReply, DbType.String);
            collection.Add("@IsReply", publishData.IsReply, DbType.Boolean);
            collection.Add("@TitleMin", publishData.TitleMin, DbType.Int32);
            collection.Add("@TitleMax", publishData.TitleMax, DbType.Int32);
            collection.Add("@ContentMin", publishData.ContentMin, DbType.Int32);
            collection.Add("@ContentMax", publishData.ContentMax, DbType.Int32);
            collection.Add("@IsUbb", publishData.IsUbb, DbType.Boolean);
            collection.Add("@IsCrlf", publishData.IsCrlf, DbType.Boolean);
            collection.Add("@CodePage", publishData.CodePage, DbType.String);
            collection.Add("@IsForcePost", publishData.IsForcePost, DbType.Boolean);
            collection.Add("@PostSort", publishData.PostSort, DbType.Int32);
            collection.Add("@IsSelfChk", publishData.IsSelfChk, DbType.Boolean);
            collection.Add("@ChkMode", publishData.ChkMode, DbType.Int32);
            collection.Add("@PostTitle", publishData.PostTitle, DbType.String);
            collection.Add("@PostContent", publishData.PostContent, DbType.String);
            collection.Add("@PostParas", publishData.PostParas, DbType.String);
            collection.Add("@PostOtherParas", publishData.PostOtherParas, DbType.String);
            collection.Add("@PostUsers", publishData.PostUsers, DbType.String);
            collection.Add("@IsFtp", publishData.IsFtp, DbType.Boolean);
            collection.Add("@IsFtpPasv", publishData.IsFtpPasv, DbType.Boolean);
            collection.Add("@FtpServer", publishData.FtpServer, DbType.String);
            collection.Add("@FtpPort", publishData.FtpPort, DbType.Int32);
            collection.Add("@FtpUser", publishData.FtpUser, DbType.String);
            collection.Add("@FtpPass", publishData.FtpPass, DbType.String);
            collection.Add("@FtpDir", publishData.FtpDir, DbType.String);
            collection.Add("@IsDelDownFile", publishData.IsDelDownFile, DbType.Boolean);
            collection.Add("@TransLang", publishData.TransLang, DbType.Int32);
            collection.Add("@TransParas", publishData.TransParas, DbType.String);
            collection.Add("@IsLogin", publishData.IsLogin, DbType.Boolean);
            collection.Add("@LoginUrl", publishData.LoginUrl, DbType.String);
            collection.Add("@PostCookies", publishData.PostCookies, DbType.String);
            collection.Add("@PostOkCode", publishData.PostOkCode, DbType.String);
            collection.Add("@Sort", publishData.Sort, DbType.Int32);
            collection.Add("@ClassID", publishData.ClassID, DbType.Int32);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        public static int UpdPublishData(PublishData publishData)
        {
            sql = "update Rule_Publish set Name=@Name,UrlChk=@UrlChk,UrlPost=@UrlPost,UrlReply=@UrlReply,IsReply=@IsReply,TitleMin=@TitleMin,TitleMax=@TitleMax,ContentMin=@ContentMin,ContentMax=@ContentMax,IsUbb=@IsUbb,IsCrlf=@IsCrlf,CodePage=@CodePage,IsForcePost=@IsForcePost,PostSort=@PostSort,IsSelfChk=@IsSelfChk,ChkMode=@ChkMode,PostTitle=@PostTitle,PostContent=@PostContent,PostParas=@PostParas,PostOtherParas=@PostOtherParas,PostUsers=@PostUsers,IsFtp=@IsFtp,IsFtpPasv=@IsFtpPasv,FtpServer=@FtpServer,FtpPort=@FtpPort,FtpUser=@FtpUser,FtpPass=@FtpPass,FtpDir=@FtpDir,IsDelDownFile=@IsDelDownFile,TransLang=@TransLang,TransParas=@TransParas,IsLogin=@IsLogin,LoginUrl=@LoginUrl,PostCookies=@PostCookies,PostOkCode=@PostOkCode,Sort=@Sort,ClassID=@ClassID where ID=@ID";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@ID", publishData.ID, DbType.Int32);
            collection.Add("@Name", publishData.Name, DbType.String);
            collection.Add("@UrlChk", publishData.UrlChk, DbType.String);
            collection.Add("@UrlPost", publishData.UrlPost, DbType.String);
            collection.Add("@UrlReply", publishData.UrlReply, DbType.String);
            collection.Add("@IsReply", publishData.IsReply, DbType.Boolean);
            collection.Add("@TitleMin", publishData.TitleMin, DbType.Int32);
            collection.Add("@TitleMax", publishData.TitleMax, DbType.Int32);
            collection.Add("@ContentMin", publishData.ContentMin, DbType.Int32);
            collection.Add("@ContentMax", publishData.ContentMax, DbType.Int32);
            collection.Add("@IsUbb", publishData.IsUbb, DbType.Boolean);
            collection.Add("@IsCrlf", publishData.IsCrlf, DbType.Boolean);
            collection.Add("@CodePage", publishData.CodePage, DbType.String);
            collection.Add("@IsForcePost", publishData.IsForcePost, DbType.Boolean);
            collection.Add("@PostSort", publishData.PostSort, DbType.Int32);
            collection.Add("@IsSelfChk", publishData.IsSelfChk, DbType.Boolean);
            collection.Add("@ChkMode", publishData.ChkMode, DbType.Int32);
            collection.Add("@PostTitle", publishData.PostTitle, DbType.String);
            collection.Add("@PostContent", publishData.PostContent, DbType.String);
            collection.Add("@PostParas", publishData.PostParas, DbType.String);
            collection.Add("@PostOtherParas", publishData.PostOtherParas, DbType.String);
            collection.Add("@PostUsers", publishData.PostUsers, DbType.String);
            collection.Add("@IsFtp", publishData.IsFtp, DbType.Boolean);
            collection.Add("@IsFtpPasv", publishData.IsFtpPasv, DbType.Boolean);
            collection.Add("@FtpServer", publishData.FtpServer, DbType.String);
            collection.Add("@FtpPort", publishData.FtpPort, DbType.Int32);
            collection.Add("@FtpUser", publishData.FtpUser, DbType.String);
            collection.Add("@FtpPass", publishData.FtpPass, DbType.String);
            collection.Add("@FtpDir", publishData.FtpDir, DbType.String);
            collection.Add("@IsDelDownFile", publishData.IsDelDownFile, DbType.Boolean);
            collection.Add("@TransLang", publishData.TransLang, DbType.Int32);
            collection.Add("@TransParas", publishData.TransParas, DbType.String);
            collection.Add("@IsLogin", publishData.IsLogin, DbType.Boolean);
            collection.Add("@LoginUrl", publishData.LoginUrl, DbType.String);
            collection.Add("@PostCookies", publishData.PostCookies, DbType.String);
            collection.Add("@PostOkCode", publishData.PostOkCode, DbType.String);
            collection.Add("@Sort", publishData.Sort, DbType.Int32);
            collection.Add("@ClassID", publishData.ClassID, DbType.Int32);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        public static int DelPublishData(int ID)
        {
            sql = "delete Rule_Publish where ID=@ID";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@ID", ID, DbType.Int32);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        public static int UpdPublishName(int ID, string name)
        {
            sql = "update Rule_Publish set Name=@Name where ID=@ID";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@ID", ID, DbType.Int32);
            collection.Add("@Name", name, DbType.String);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        public static int GetMaxPublishID()
        {
            sql = "select Max(ID) from Rule_Publish";
            return int.Parse(dataAccess.ExecuteScalar(sql).ToString());
        }


        #endregion       

        #region Rule_Class ok
        public static List<ClassData> GetClassNameList(string classType)
        {
            List<ClassData> classNameList = new List<ClassData>();

            sql = "select * from Rule_Class where ClassType = @ClassType";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@ClassType", classType, DbType.String);

            DataTable resultTable = dataAccess.ExecuteDataset(sql, collection).Tables[0];
            if (resultTable != null && resultTable.Rows.Count > 0)
            {
                foreach(DataRow row in resultTable.Rows)
                {
                    ClassData classData = new ClassData();
                    classData.ClassID = TypeConverter.ObjectToInt(row["ClassID"]);
                    classData.ClassName = row["ClassName"].ToString();
                    classData.ClassType = row["ClassType"].ToString();
                    classData.Sort = TypeConverter.ObjectToInt(row["Sort"]);

                    classNameList.Add(classData);
                }
            }

            return classNameList;
        }

        public static int InsClassData(ClassData classData)
        {
            sql = "insert into Rule_Class(ClassType,ClassName,Sort) values(@ClassType,@ClassName,@Sort)";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@ClassType", classData.ClassType, DbType.String);
            collection.Add("@ClassName", classData.ClassName, DbType.String);
            collection.Add("@Sort", classData.Sort, DbType.Int32);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        public static int DelClassData(int classID)
        {
            sql = "delete Rule_Class where ClassID=@ClassID";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@ClassID", classID, DbType.Int32);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        public static int UpdClassData(ClassData classData)
        {
            sql = "update Rule_Class set ClassName=@ClassName,ClassType=@ClassType,Sort=@Sort where ClassID=@ClassID";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@ClassID", classData.ClassID, DbType.Int32);
            collection.Add("@ClassName", classData.ClassName, DbType.String);
            collection.Add("@ClassType", classData.ClassType, DbType.String);
            collection.Add("@Sort", classData.Sort, DbType.Int32);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        public static int UpdClassName(int classID, string className)
        {
            sql = "update Rule_Class set ClassName=@ClassName where ClassID=@ClassID";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@ClassID", classID, DbType.Int32);
            collection.Add("@ClassName", className, DbType.String);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }



        public static int GetMaxClassID(string classType)
        {
            sql = "select Max(ClassID) from Rule_Class";
            return int.Parse(dataAccess.ExecuteScalar(sql).ToString());
        }

        #endregion





        #region Rule_Global ok

        public static List<GlobalData> GetGlobalDataList(int ClassID)
        {
            List<GlobalData> globalDataList = new List<GlobalData>();

            sql = "select * from Rule_Global where ClassID = @ClassID";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@ClassID", ClassID, DbType.Int32);

            DataTable resultTable = dataAccess.ExecuteDataset(sql, collection).Tables[0];
            if(resultTable != null && resultTable.Rows.Count > 0)
            {
                foreach(DataRow row in resultTable.Rows)
                {
                    GlobalData globalData = new GlobalData();
                    globalData.ID = TypeConverter.ObjectToInt(row["ID"]);
                    globalData.Name = row["Name"].ToString();

                    globalDataList.Add(globalData);
                }
            }

            return globalDataList;
        }

        public static GlobalData GetGlobalData(int ID)
        {
            GlobalData globalData = new GlobalData();

            sql = "select * from Rule_Global where ID=@ID";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@ID", ID, DbType.Int32);

            dataAccess.Open();
            IDataReader reader = dataAccess.ExecuteReader(sql, collection);
            while(reader.Read())
            {
                globalData.ID = TypeConverter.StrToInt(reader["ID"].ToString());
                globalData.Name = reader["Name"].ToString();
                globalData.KeyTitle = reader["KeyTitle"].ToString();
                globalData.MgTitle = reader["MgTitle"].ToString();
                globalData.MgContent = reader["MgContent"].ToString();
                globalData.IsImgMark = TypeConverter.StrToBool(reader["IsImgMark"].ToString(), false);
                globalData.ImgMarkFile = reader["ImgMarkFile"].ToString();
                globalData.ImgWz = TypeConverter.StrToInt(reader["ImgWz"].ToString());
                globalData.ImgAlpha = TypeConverter.StrToInt(reader["ImgAlpha"].ToString());
                globalData.LogoW = TypeConverter.StrToInt(reader["LogoW"].ToString());
                globalData.LogoH = TypeConverter.StrToInt(reader["LogoH"].ToString());
                globalData.Sort = TypeConverter.StrToInt(reader["Sort"].ToString());
                globalData.ClassID = TypeConverter.StrToInt(reader["ClassID"].ToString());
            }

            dataAccess.Close();

            return globalData;
        }

        public static int InsGlobalData(GlobalData globalData)
        {
            sql = "insert into Rule_Global(Name,ClassID) values(@Name,@ClassID)";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@Name", globalData.Name, DbType.String);
            collection.Add("@ClassID", globalData.ClassID, DbType.String);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        public static int UpdGlobalData(GlobalData globalData)
        {
            sql = "update Rule_Global set KeyTitle=@KeyTitle,KeyContent=@KeyContent, MgTitle=@MgTitle,MgContent=@MgContent,Rewriter=@Rewriter,IsImgark=@IsImgark,ImgMarkFile=@ImgMarkFile,ImgWz=@ImgWz,ImgAlpha=@ImgAlpha,LogoW=@LogoW,LogoH=@LogoH where ID=@ID";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@KeyTitle", globalData.KeyTitle, DbType.String);
            collection.Add("@KeyContent", globalData.KeyContent, DbType.String);
            collection.Add("@MgTitle", globalData.MgTitle, DbType.String);
            collection.Add("@MgContent", globalData.MgContent, DbType.String);
            collection.Add("@Rewriter", globalData.Rewriter, DbType.String);
            collection.Add("@IsImgMark", globalData.IsImgMark, DbType.Boolean);
            collection.Add("@ImgMarkFile", globalData.ImgMarkFile, DbType.String);
            collection.Add("@ImgWz", globalData.ImgWz, DbType.Int32);
            collection.Add("@ImgAlpha", globalData.ImgAlpha, DbType.Int32);
            collection.Add("@LogoW", globalData.LogoW, DbType.Int32);
            collection.Add("@LogoH", globalData.LogoH, DbType.Int32);
            collection.Add("@ID", globalData.ID, DbType.Int32);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        public static int DelGlobalData(int ID)
        {
            sql = "delete Rule_Global where ID=@ID";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@ID", ID, DbType.Int32);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        public static int GetMaxGlobalID()
        {
            sql = "select Max(ID) from Rule_Global";
            return int.Parse(dataAccess.ExecuteScalar(sql).ToString());
        }

        #endregion

        //#region Rule_Plan ok
        //public static List<PlanData> GetPlanNameList(int ClassID)
        //{
        //    List<PlanData> planDataList = new List<PlanData>();

        //    sql = "select ID,Name from Rule_Plan where ClassID = @ClassID";

        //    QueryParameterCollection collection = new QueryParameterCollection();
        //    collection.Add("@ClassID", ClassID, DbType.Int32);

        //    DataTable resultTable = dataAccess.ExecuteDataset(sql, collection).Tables[0];
        //    if(resultTable != null && resultTable.Rows.Count > 0)
        //    {
        //        foreach(DataRow row in resultTable.Rows)
        //        {
        //            PlanData planData = new PlanData();
        //            planData.ID = TypeConverter.ObjectToInt(row["ID"]);
        //            planData.Name = row["Name"].ToString();

        //            planDataList.Add(planData);
        //        }
        //    }

        //    return planDataList;
        //}

        //public static PlanData GetPlanData(int ID)
        //{
        //    PlanData planData = new PlanData();

        //    sql = "select * from Rule_Plan where ID=@ID";

        //    QueryParameterCollection collection = new QueryParameterCollection();
        //    collection.Add("@ID", ID, DbType.Int32);

        //    IDataReader reader = dataAccess.ExecuteReader(sql, collection);
        //    while(reader.Read())
        //    {
        //        planData.ID = TypeConverter.StrToInt(reader["id"].ToString());
        //        planData.Name = reader["name"].ToString();
        //        planData.RuleGet = TypeConverter.StrToInt(reader["RuleGet"].ToString());
        //        planData.RuleGlobal = TypeConverter.StrToInt(reader["RuleGlobal"].ToString());
        //        planData.RulePostType = TypeConverter.StrToInt(reader["RulePostType"].ToString());
        //        planData.RulePost = TypeConverter.StrToInt(reader["RulePost"].ToString());
        //        planData.PlanDelay = TypeConverter.StrToInt(reader["PlanDelay"].ToString());
        //        planData.IsAutoTime = TypeConverter.StrToBool(reader["IsAutoTime"].ToString(), false);
        //        planData.AutoTime = reader["AutoTime"].ToString();
        //        planData.Sort = TypeConverter.StrToInt(reader["Sort"].ToString());
        //        planData.ClassID = TypeConverter.StrToInt(reader["ClassID"].ToString());
        //    }

        //    return planData;
        //}

        //public static int InsPlanData(PlanData planData)
        //{
        //    sql = "insert into Rule_Plan(Name,ClassID) values(@Name,@ClassID)";

        //    QueryParameterCollection collection = new QueryParameterCollection();
        //    collection.Add("@Name", planData.Name, DbType.Int32);
        //    collection.Add("@ClassID", planData.ClassID, DbType.String);

        //    return dataAccess.ExecuteNonQuery(sql, collection);
        //}

        //public static int UpdPlanData(PlanData planData)
        //{
        //    sql = "update Rule_Plan set Name=@Name,RuleGet=@RuleGet,RuleGlobal=@RuleGlobal,RulePostType=@RulePostType,RulePost=@RulePost,PlanDelay=@PlanDelay,IsAutoTime=@IsAutoTime,AutoTime=@AutoTime,Sort=@Sort,ClassID=@ClassID where ID=@ID";

        //    QueryParameterCollection collection = new QueryParameterCollection();
        //    collection.Add("@ID", planData.ID, DbType.Int32);
        //    collection.Add("@Name", planData.Name, DbType.String);
        //    collection.Add("@RuleGet", planData.RuleGet, DbType.Int32);
        //    collection.Add("@RuleGlobal", planData.RuleGlobal, DbType.Int32);
        //    collection.Add("@RulePostType", planData.RulePostType, DbType.Int32);
        //    collection.Add("@RulePost", planData.RulePost, DbType.Int32);
        //    collection.Add("@PlanDelay", planData.PlanDelay, DbType.Int32);
        //    collection.Add("@IsAutoTime", planData.IsAutoTime, DbType.Boolean);
        //    collection.Add("@AutoTime", planData.AutoTime, DbType.String);
        //    collection.Add("@Sort", planData.Sort, DbType.Int32);
        //    collection.Add("@ClassID", planData.ClassID, DbType.Int32);

        //    return dataAccess.ExecuteNonQuery(sql, collection);
        //}

        //public static int DelPlanData(int ID)
        //{
        //    sql = "delete Rule_Plan where ID=@ID";

        //    QueryParameterCollection collection = new QueryParameterCollection();
        //    collection.Add("@ID", ID, DbType.Int32);

        //    return dataAccess.ExecuteNonQuery(sql, collection);
        //}

        //#endregion

        //#region Rule_Plan
        //public static List<PlanData> GetPlanDataList(int ID)
        //{

        //    List<PlanData> planDataList = new List<PlanData>();

        //    sql = "select * from Rule_Plan";


        //    if(ID != null)
        //    {
        //        sql += " where ID=" + ID;
        //    }

        //    DataSet ds = DataHelper.dataAccess.ExecuteDataset(sql);
        //    DataTable table = ds.Tables[0];

        //    if(table != null && table.Rows.Count > 0)
        //    {
        //        foreach(DataRow row in table.Rows)
        //        {
        //            PlanData planData = new PlanData();
        //            planData.PlanID = int.Parse(row["ID"].ToString());
        //            planData.PlanName = row["PlanName"].ToString();
        //            planData.PlanState = int.Parse(row["PlanState"].ToString());
        //            planData.IsOverRun = row["IsOverRun"].ToString() == "True" ? true : false;
        //            planData.IsDisabled = row["IsDisabled"].ToString() == "True" ? true : false;
        //            planData.DisabledType = int.Parse(row["DisabledType"].ToString());
        //            planData.DisabledTime = int.Parse(row["DisabledTime"].ToString());
        //            planData.DisabledDateTime = DateTime.Parse(row["DisabledDateTime"].ToString());
        //            planData.RunTaskPlanType = int.Parse(row["RunTaskPlanType"].ToString());
        //            planData.EnabledDateTime = row["EnabledDateTime"].ToString();
        //            planData.RunOnesTime = row["RunOnesTime"].ToString();
        //            planData.RunDayTime = row["RunDayTime"].ToString();
        //            planData.RunAMTime = row["RunAMTime"].ToString();
        //            planData.RunPMTime = row["RunPMTime"].ToString();
        //            planData.RunWeeklyTime = row["RunWeeklyTime"].ToString();
        //            planData.RunWeekly = row["RunWeekly"].ToString();
        //            planData.RunTimeCount = row["RunTimeCount"].ToString();
        //            planData.FirstRunTime = row["FirstRunTime"].ToString();
        //            planData.RunInterval = row["RunInterval"].ToString();
        //            planData.RunTaskType = row["RunTaskType"].ToString();
        //            planData.RunTaskName = row["RunTaskName"].ToString();
        //            planData.RunTaskPara = row["RunTaskPara"].ToString();

        //            string[] runTaskType = planData.RunTaskType.Split(new char[] { (char)13 });
        //            string[] runTaskName = planData.RunTaskName.Split(new char[] { (char)13 });
        //            string[] runTaskPara = planData.RunTaskPara.Split(new char[] { (char)13 });

        //            for(int i = 0; i < runTaskType.Length; i++)
        //            {
        //                PlanTaskData planTaskData = new PlanTaskData();
        //                planTaskData.RunTaskType = runTaskType[i];
        //                planTaskData.RunTaskName = runTaskName[i];
        //                planTaskData.RunTaskPara = runTaskPara[i];

        //                planData.PlanTasks.Add(planTaskData);
        //            }

        //            planDataList.Add(planData);
        //        }
        //    }

        //    return planDataList;
        //}

        //public static int InsPlanData(PlanData planData)
        //{
        //    sql = "insert into Rule_Plan(PlanName,PlanState,PlanRemark,IsOverRun,IsDisabled,DisabledType,DisabledTime,DisabledDateTime,RunTaskPlanType,EnabledDateTime,RunOnesTime,RunDayTime,RunAMTime,RunPMTime,RunWeeklyTime,RunWeekly,FirstRunTime,RunInterval,RunTimeCount,RunTaskType,RunTaskName,RunTaskPara) values(@PlanName,@PlanState,@PlanRemark,@IsOverRun,@IsDisabled,@DisabledType,@DisabledTime,@DisabledDateTime,@RunTaskPlanType,@EnabledDateTime,@RunOnesTime,@RunDayTime,@RunAMTime,@RunPMTime,@RunWeeklyTime,@RunWeekly,@FirstRunTime,@RunInterval,@RunTimeCount,@RunTaskType,@RunTaskName,@RunTaskPara)";

        //    collection = new QueryParameterCollection();
        //    collection.Add("@PlanName", planData.PlanName, DbType.String);
        //    collection.Add("@PlanState", planData.PlanState, DbType.Int32);
        //    collection.Add("@PlanRemark", planData.PlanRemark, DbType.String);
        //    collection.Add("@IsOverRun", planData.IsOverRun, DbType.Boolean);
        //    collection.Add("@IsDisabled", planData.IsDisabled, DbType.Boolean);
        //    collection.Add("@DisabledType", planData.DisabledType, DbType.Int32);
        //    collection.Add("@DisabledTime", planData.DisabledTime, DbType.Int32);
        //    collection.Add("@DisabledDateTime", planData.DisabledDateTime, DbType.DateTime);
        //    collection.Add("@RunTaskPlanType", planData.RunTaskPlanType, DbType.Int32);
        //    collection.Add("@EnabledDateTime", planData.EnabledDateTime, DbType.String);
        //    collection.Add("@RunOnesTime", planData.RunOnesTime, DbType.String);
        //    collection.Add("@RunDayTime", planData.RunDayTime, DbType.String);
        //    collection.Add("@RunAMTime", planData.RunAMTime, DbType.String);
        //    collection.Add("@RunPMTime", planData.RunPMTime, DbType.String);
        //    collection.Add("@RunWeeklyTime", planData.RunWeeklyTime, DbType.String);
        //    collection.Add("@RunWeekly", planData.RunWeekly, DbType.String);
        //    collection.Add("@FirstRunTime", planData.FirstRunTime, DbType.String);
        //    collection.Add("@RunInterval", planData.RunInterval, DbType.String);
        //    collection.Add("@RunTimeCount", planData.RunTimeCount, DbType.String);

        //    foreach(PlanTaskData planTaskData in planData.PlanTasks)
        //    {
        //        planData.RunTaskType += planTaskData.RunTaskType + new StringBuilder().Append((char)13).ToString();
        //        planData.RunTaskName += planTaskData.RunTaskName + new StringBuilder().Append((char)13).ToString();
        //        planData.RunTaskPara += planTaskData.RunTaskPara + new StringBuilder().Append((char)13).ToString();
        //    }

        //    collection.Add("@RunTaskType", planData.RunTaskType, DbType.String);
        //    collection.Add("@RunTaskName", planData.RunTaskName, DbType.String);
        //    collection.Add("@RunTaskPara", planData.RunTaskPara, DbType.String);

        //    return dataAccess.ExecuteNonQuery(sql, collection);
        //}

        //public static int UpdPlanData(PlanData planData)
        //{
        //    sql = "update Rule_Plan set PlanName=@PlanName,PlanState=@PlanState,PlanRemark=@PlanRemark,IsOverRun=@IsOverRun,IsDisabled=@IsDisabled,DisabledType=@DisabledType,DisabledTime=@DisabledTime,DisabledDateTime=@DisabledDateTime,RunTaskPlanType=@RunTaskPlanType,EnabledDateTime=@EnabledDateTime,RunOnesTime=@RunOnesTime,RunDayTime=@RunDayTime,RunAMTime=@RunAMTime,RunPMTime=@RunPMTime,RunWeeklyTime=@RunWeeklyTime,RunWeekly=@RunWeekly,FirstRunTime=@FirstRunTime,RunInterval=@RunInterval,RunTimeCount=@RunTimeCount,RunTaskType=@RunTaskType,RunTaskName=@RunTaskName,RunTaskPara=@RunTaskPara where ID=@ID";

        //    collection = new QueryParameterCollection();
        //    collection.Add("@ID", planData.ID, DbType.Int32);
        //    collection.Add("@PlanName", planData.PlanName, DbType.String);
        //    collection.Add("@PlanState", planData.PlanState, DbType.Int32);
        //    collection.Add("@PlanRemark", planData.PlanRemark, DbType.String);
        //    collection.Add("@IsOverRun", planData.IsOverRun, DbType.Boolean);
        //    collection.Add("@IsDisabled", planData.IsDisabled, DbType.Boolean);
        //    collection.Add("@DisabledType", planData.DisabledType, DbType.Int32);
        //    collection.Add("@DisabledTime", planData.DisabledTime, DbType.Int32);
        //    collection.Add("@DisabledDateTime", planData.DisabledDateTime, DbType.DateTime);
        //    collection.Add("@RunTaskPlanType", planData.RunTaskPlanType, DbType.Int32);
        //    collection.Add("@EnabledDateTime", planData.EnabledDateTime, DbType.String);
        //    collection.Add("@RunOnesTime", planData.RunOnesTime, DbType.String);
        //    collection.Add("@RunDayTime", planData.RunDayTime, DbType.String);
        //    collection.Add("@RunAMTime", planData.RunAMTime, DbType.String);
        //    collection.Add("@RunPMTime", planData.RunPMTime, DbType.String);
        //    collection.Add("@RunWeeklyTime", planData.RunWeeklyTime, DbType.String);
        //    collection.Add("@RunWeekly", planData.RunWeekly, DbType.String);
        //    collection.Add("@FirstRunTime", planData.FirstRunTime, DbType.String);
        //    collection.Add("@RunInterval", planData.RunInterval, DbType.String);
        //    collection.Add("@RunTimeCount", planData.RunTimeCount, DbType.String);

        //    return dataAccess.ExecuteNonQuery(sql, collection);
        //}

        //public static int DelPlanData(int ID)
        //{
        //    sql = "delete from Rule_Plan where ID=@ID";
        //    collection = new QueryParameterCollection();
        //    collection.Add("@ID", ID, DbType.Int32);

        //    return dataAccess.ExecuteNonQuery(sql, collection);
        //}

        //public static void IfEnabled(int ID, bool onlyState)
        //{
        //    PlanData p = GetPlanDataList(ID)[0];

        //    if(p.IsDisabled == false)
        //    {
        //        p = null;
        //        return;
        //    }

        //    if(p.DisabledType == (int)Const.PlanDisabledType.RunTime)
        //    {
        //        if(p.DisabledTime < int.Parse(p.RunTimeCount) + 1)
        //        {
        //            p.PlanState = (int)Const.PlanState.Disabled;
        //        }
        //        else if(onlyState == false)
        //        {
        //            p.RunTimeCount = int.Parse(p.RunTimeCount + 1).ToString();
        //        }
        //    }
        //    else if(p.DisabledType == (int)Const.PlanDisabledType.RunDateTime)
        //    {
        //        if(DateTime.Compare(DateTime.Now, p.DisabledDateTime) < 0)
        //        {
        //            p.PlanState = (int)Const.PlanState.Disabled;
        //        }
        //    }

        //    UpdPlanData(p);
        //}

        //#endregion

        //#region rule_post
        //public static List<cPublishWebData> GetPublishWebDataNameList(int classID)
        //{
        //    List<cPublishWebData> publishWebDataList = new List<cPublishWebData>();

        //    sql = "select id,name from rule_post where g_id = @g_id";

        //    QueryParameterCollection collection = new QueryParameterCollection();
        //    collection.Add("@g_id", classID, DbType.Int32);

        //    DataTable publishWebDataTable = dataAccess.ExecuteDataset(sql, collection).Tables[0];
        //    if(publishWebDataTable != null && publishWebDataTable.Rows.Count > 0)
        //    {
        //        foreach(DataRow row in publishWebDataTable.Rows)
        //        {
        //            cPublishWebData publishWebData = new cPublishWebData();
        //            publishWebData.ID = TypeConverter.ObjectToInt(row["id"]);
        //            publishWebData.Name = row["name"].ToString();

        //            publishWebDataList.Add(publishWebData);
        //        }
        //    }

        //    return publishWebDataList;
        //}

        //public static cPublishWebData GetPublishWebData(int id)
        //{
        //    cPublishWebData publishWebData = new cPublishWebData();

        //    sql = "select * from rule_post where id=@id";

        //    QueryParameterCollection collection = new QueryParameterCollection();
        //    collection.Add("@id", id, DbType.Int32);

        //    IDataReader reader = dataAccess.ExecuteReader(sql, collection);
        //    while(reader.Read())
        //    {
        //        publishWebData.ID = TypeConverter.StrToInt(reader["id"].ToString());
        //        publishWebData.Name = reader["name"].ToString();
        //        publishWebData.UrlChk = reader["URLchk"].ToString();
        //        publishWebData.UrlPost = reader["URLpost"].ToString();
        //        publishWebData.UrlReply = reader["URLreply"].ToString();
        //        publishWebData.IsReply = TypeConverter.StrToBool(reader["isreply"].ToString(), false);
        //        publishWebData.LenTitleMin = TypeConverter.StrToInt(reader["Len_t_s"].ToString());
        //        publishWebData.LenTitleMax = TypeConverter.StrToInt(reader["Len_t_l"].ToString());
        //        publishWebData.LenContentMin = TypeConverter.StrToInt(reader["Len_c_s"].ToString());
        //        publishWebData.LenContentMax = TypeConverter.StrToInt(reader["len_c_l"].ToString());
        //        publishWebData.PostTitle = reader["ptitle"].ToString();
        //        publishWebData.PostContent = reader["pcontent"].ToString();
        //        publishWebData.PostUser = reader["puser"].ToString();
        //        publishWebData.PostPass = reader["ppsw"].ToString();
        //        publishWebData.PostPara1 = reader["para1"].ToString();
        //        publishWebData.Userlist = reader["userlist"].ToString();
        //        publishWebData.Paralist = reader["paralist"].ToString();
        //        publishWebData.IsFtp = TypeConverter.StrToBool(reader["FTP"].ToString(), false);
        //        publishWebData.FtpServer = reader["FTPserver"].ToString();
        //        publishWebData.FtpPort = TypeConverter.StrToInt(reader["FTPport"].ToString());
        //        publishWebData.FtpUser = reader["FTPuser"].ToString();
        //        publishWebData.FtpPass = reader["FTPpsw"].ToString();
        //        publishWebData.FtpPasv = reader["FTPpasv"].ToString();
        //        publishWebData.YmUpDir = reader["ymupdir"].ToString();
        //        publishWebData.CodePage = TypeConverter.StrToInt(reader["codepage"].ToString());
        //        publishWebData.TransLang = TypeConverter.StrToInt(reader["TransLang"].ToString());
        //        publishWebData.TransParas = reader["TransParas"].ToString();
        //        publishWebData.PathFile = reader["pathfile"].ToString();
        //        publishWebData.UrlFile = reader["URLfile"].ToString();
        //        publishWebData.PostFiles = reader["pfiles"].ToString();
        //        publishWebData.PostUrl = reader["psurl"].ToString();
        //        publishWebData.IsLoginPost = TypeConverter.StrToBool(reader["isloginpost"].ToString(), false);
        //        publishWebData.PostCookies = reader["postcookies"].ToString();
        //        publishWebData.PostOkCode = reader["postokcode"].ToString();
        //        publishWebData.PostAddUrl = reader["postaddurl"].ToString();
        //        publishWebData.IsUbb = TypeConverter.StrToBool(reader["isubb"].ToString(), false);
        //        publishWebData.IsCrlf = TypeConverter.StrToBool(reader["iscrlf"].ToString(), false);
        //        publishWebData.Sort = TypeConverter.StrToInt(reader["sn"].ToString());
        //        publishWebData.ClassID = TypeConverter.StrToInt(reader["g_id"].ToString());
        //    }

        //    return publishWebData;
        //}

        //public static int InsPublishWebData(cPublishWebData publishWebData)
        //{
        //    sql = "insert into rule_post(name,g_id) values(@name,@g_id)";

        //    QueryParameterCollection collection = new QueryParameterCollection();
        //    collection.Add("@name", publishWebData.ID, DbType.Int32);
        //    collection.Add("@g_id", publishWebData.ClassID, DbType.String);

        //    return dataAccess.ExecuteNonQuery(sql, collection);
        //}

        //public static int UpdPublishWebData(cPublishWebData publishWebData)
        //{
        //    sql = "update rule_post set name=@name,URLchk=@URLchk,URLpost=@URLpost,URLreply=@URLreply,isreply=@isreply,Len_t_s=@Len_t_s,Len_t_l=@Len_t_l,Len_c_s=@Len_c_s,len_c_l=@len_c_l,ptitle=@ptitle,pcontent=@pcontent,puser=@puser,ppsw=@ppsw,para1=@para1,userlist=@userlist,paralist=@paralist,FTP=@FTP,FTPserver=@FTPserver,FTPport=@FTPport,FTPuser=@FTPuser,FTPpsw=@FTPpsw,FTPpasv=@FTPpasv,ymupdir=@ymupdir,codepage=@codepage,TransLang=@TransLang,TransParas=@TransParas,pathfile=@pathfile,URLfile=@URLfile,pfiles=@pfiles,psurl=@psurl,isloginpost=@isloginpost,postcookies=@postcookies,postokcode=@postokcode,postaddurl=@postaddurl,isubb=@isubb,iscrlf=@iscrlf,sn=@sn,g_id=@g_id where id=@id";

        //    QueryParameterCollection collection = new QueryParameterCollection();
        //    collection.Add("@name", publishWebData.Name, DbType.String);
        //    collection.Add("@URLchk", publishWebData.UrlChk, DbType.String);
        //    collection.Add("@URLpost", publishWebData.UrlPost, DbType.String);
        //    collection.Add("@URLreply", publishWebData.UrlReply, DbType.String);
        //    collection.Add("@isreply", publishWebData.IsReply, DbType.Boolean);
        //    collection.Add("@Len_t_s", publishWebData.LenTitleMin, DbType.Int32);
        //    collection.Add("@Len_t_l", publishWebData.LenTitleMax, DbType.Int32);
        //    collection.Add("@Len_c_s", publishWebData.LenContentMin, DbType.Int32);
        //    collection.Add("@len_c_l", publishWebData.LenContentMax, DbType.Int32);
        //    collection.Add("@ptitle", publishWebData.PostTitle, DbType.String);
        //    collection.Add("@pcontent", publishWebData.PostContent, DbType.String);
        //    collection.Add("@puser", publishWebData.PostUser, DbType.String);
        //    collection.Add("@ppsw", publishWebData.PostPass, DbType.String);
        //    collection.Add("@para1", publishWebData.PostPara1, DbType.String);
        //    collection.Add("@userlist", publishWebData.Userlist, DbType.String);
        //    collection.Add("@paralist", publishWebData.Paralist, DbType.String);
        //    collection.Add("@FTP", publishWebData.IsFtp, DbType.String);
        //    collection.Add("@FTPserver", publishWebData.FtpServer, DbType.String);
        //    collection.Add("@FTPport", publishWebData.FtpPort, DbType.Int32);
        //    collection.Add("@FTPuser", publishWebData.FtpUser, DbType.String);
        //    collection.Add("@FTPpsw", publishWebData.FtpPass, DbType.String);
        //    collection.Add("@FTPpasv", publishWebData.FtpPasv, DbType.Boolean);
        //    collection.Add("@ymupdir", publishWebData.YmUpDir, DbType.Boolean);
        //    collection.Add("@codepage", publishWebData.CodePage, DbType.Int32);
        //    collection.Add("@TransLang", publishWebData.TransLang, DbType.Int32);
        //    collection.Add("@TransParas", publishWebData.TransParas, DbType.String);
        //    collection.Add("@pathfile", publishWebData.PathFile, DbType.String);
        //    collection.Add("@URLfile", publishWebData.UrlFile, DbType.String);
        //    collection.Add("@pfiles", publishWebData.PostFiles, DbType.String);
        //    collection.Add("@psurl", publishWebData.PostUrl, DbType.String);
        //    collection.Add("@isloginpost", publishWebData.IsLoginPost, DbType.Boolean);
        //    collection.Add("@postcookies", publishWebData.PostCookies, DbType.String);
        //    collection.Add("@postokcode", publishWebData.PostOkCode, DbType.String);
        //    collection.Add("@postaddurl", publishWebData.PostAddUrl, DbType.String);
        //    collection.Add("@isubb", publishWebData.IsUbb, DbType.Boolean);
        //    collection.Add("@iscrlf", publishWebData.IsCrlf, DbType.Boolean);
        //    collection.Add("@sn", publishWebData.Sort, DbType.Int32);
        //    collection.Add("@g_id", publishWebData.ClassID, DbType.Int32);
        //    collection.Add("@id", publishWebData.ID, DbType.Int32);

        //    return dataAccess.ExecuteNonQuery(sql, collection);
        //}

        //public static int DelPublishWebData(int id)
        //{
        //    sql = "delete rule_post where id=@id";

        //    QueryParameterCollection collection = new QueryParameterCollection();
        //    collection.Add("@id", id, DbType.Int32);

        //    return dataAccess.ExecuteNonQuery(sql, collection);
        //}

        //#endregion


        /* OK ***************::*/

        #region list ok

        public static List<PageUrlData> GetPageUrlDataList(int planID)
        {
            List<PageUrlData> pageUrlDataList = new List<PageUrlData>();

            sql = "select * from list where planid = @planid";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@planid", planID, DbType.Int32);

            DataTable resultTable = dataAccess.ExecuteDataset(sql, collection).Tables[0];
            if(resultTable != null && resultTable.Rows.Count > 0)
            {
                foreach(DataRow row in resultTable.Rows)
                {
                    PageUrlData pageUrlData = new PageUrlData();
                    pageUrlData.ID = TypeConverter.StrToInt(row["id"].ToString());
                    pageUrlData.PlanID = TypeConverter.StrToInt(row["planid"].ToString());
                    pageUrlData.Title = row["title"].ToString();
                    pageUrlData.Link = row["link"].ToString();
                    pageUrlData.LitPic = row["litpic"].ToString();
                    pageUrlData.PostTime = TypeConverter.StrToDateTime(row["posttime"].ToString());
                    pageUrlData.ActionFlag = TypeConverter.StrToBool(row["actionflag"].ToString(), false);
                    pageUrlData.PostFlag = TypeConverter.StrToBool(row["postflag"].ToString(), false);
                    pageUrlData.ChkFlag = TypeConverter.StrToBool(row["chkflag"].ToString(), false);
                    pageUrlData.ErrFlag = TypeConverter.StrToInt(row["errflag"].ToString());

                    pageUrlDataList.Add(pageUrlData);
                }
            }

            return pageUrlDataList;
        }

        public static int InsPageUrlData(PageUrlData pageUrlData)
        {
            sql = "insert into list(planid,title,link,litpic,posttime,actionflag,postflag,chkflag,errflag) values(@planid,@title,@link,@litpic,@posttime,@actionflag,@postflag,@chkflag,@errflag)";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@planid", pageUrlData.PlanID, DbType.Int32);
            collection.Add("@title", pageUrlData.Title, DbType.String);
            collection.Add("@link", pageUrlData.Link, DbType.String);
            collection.Add("@litpic", pageUrlData.LitPic, DbType.String);
            collection.Add("@posttime", pageUrlData.PostTime, DbType.DateTime);
            collection.Add("@actionflag", pageUrlData.ActionFlag, DbType.Boolean);
            collection.Add("@postflag", pageUrlData.PostFlag, DbType.Boolean);
            collection.Add("@chkflag", pageUrlData.ChkFlag, DbType.Boolean);
            collection.Add("@errflag", pageUrlData.ErrFlag, DbType.Int32);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        public static int UpdPageUrlData(PageUrlData pageUrlData)
        {
            sql = "update list set actionflag=@actionflag,actionflag=@actionflag,postflag=@postflag,errflag=@errflag where id=@id";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@id", pageUrlData.ID, DbType.Int32);
            collection.Add("@actionflag", pageUrlData.ActionFlag, DbType.Boolean);
            collection.Add("@postflag", pageUrlData.PostFlag, DbType.Boolean);
            collection.Add("@chkflag", pageUrlData.ChkFlag, DbType.Boolean);
            collection.Add("@errflag", pageUrlData.ErrFlag, DbType.Int32);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        public static int DelPageUrlData(int id)
        {
            sql = "delete list where id=@id";

            QueryParameterCollection collection = new QueryParameterCollection();
            collection.Add("@id", id, DbType.Int32);

            return dataAccess.ExecuteNonQuery(sql, collection);
        }

        #endregion

        


    }
}
